#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "detail/bmock_arg_checker.hpp"
#include "detail/bmock_test_control_tools.hpp"
#include <boost/bind.hpp>

namespace bmock {
	BOOST_AUTO_TEST_CASE(test_chec_args_OK) {
		const control_tools_ptr tl(new test_control_tools());
		const char              name[] = "arg";
		const char              arg1[] = "ABCDEFG";
		const char * const      arg2   = arg1;
		bool                    result;
		arg_checker             ac(tl);

		ac.set_location(location(__FILE__,__LINE__+1));
		BOOST_CHECK_NO_THROW(result = ac.check_arg(name,arg1,arg2));
		BOOST_CHECK(!result);
	}

	static bool sense;
	static void f() {
		sense = true;
	}

	BOOST_AUTO_TEST_CASE(test_callback_basic) {
		const control_tools_ptr tl(new test_control_tools());
		arg_checker             ac(tl);

		sense = false;
		BOOST_CHECK_NO_THROW(ac.invoke_callbacks());
		BOOST_CHECK(!sense);
		BOOST_CHECK_NO_THROW(ac.connect(boost::bind(f)));
		BOOST_CHECK_NO_THROW(ac.invoke_callbacks());
		BOOST_CHECK(sense);
	}
}